package dirfile

import (
	"io"
	"os"
)

func IsEmptyDir(path string) (bool, error) {
	// Open the directory.
	dir, err := os.Open(path)
	if err != nil {
		return false, err
	}
	defer dir.Close()

	// Read the entries in the directory.
	_, err = dir.Readdirnames(1) // Try to read up to 1 entry.
	if err == io.EOF {
		return true, nil // Directory is empty.
	}
	return false, err // Either there was an error or it's not empty.
}
